# include <stdio.h>
# include <stdlib.h>

typedef struct Link
{
    int elem;
    struct Link * next;
}link;

link * initLink(void);
void display(link * p);
link * InsertLink(link *, int elem, int add);
link * deleteLink(link *, int elem, int delet);

int main(void)
{
    link * p = initLink();
    display(p);

    return 0;
}

link * initLink(void)
{
    int i;

    link * temp = (link *)malloc(sizeof(link));
    link * p = temp;//头指针

    for(i = 1; i < 5; i++)
    {
        link * a = (link *)malloc(sizeof(link));
        a->elem = i;
        a->next = NULL;
        temp->next = a;
        temp = temp->next;//temp = a也可以
    }
    return p;
}

void display(link * p)
{
    link * temp = p->next;
    while(temp)
    {
        printf("%d ",temp->elem);
        temp = temp->next;
    }
    printf("\n");
}

link * InsertLink(link * p, int elem, int add)
{
    link * temp = p;
    link * c = NULL;

    int i = 0;
    for(i = 1; i < add; i++)
    {
        if(temp == NULL)
        {
            printf("插入位置无效！");
            return p;
        }
        temp = temp->next;
    }
    c = (link *)malloc(sizeof(link));
    c->elem = 90;
    temp->next = c;
    return p;
}

link * deleteLink(link * p, int elem, int add)
{
    return p;
}
